<%@ page language="java" pageEncoding="UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<%@ include file="../../common/common.jsp" %>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>${menu_name } - ${title }</title>
</head>
<link href="${ctx }/static/plugins/chosen_v1.6.2/chosen.css" rel="stylesheet"/>
<body
        <%@ include file="../../common/skin.jsp" %>
>
<%@ include file="../../common/head.jsp" %>
<%@ include file="../../common/menu.jsp" %>
<div class="J_content">
    <div class="mt20 plr20">
        <form action="${ctx }/law/article/list" id="queryForm" method="post">
            <div class="J_toolsBar clearfix">
                <select name="columnId" onchange="myQuery();" class="t_opacitySelect ml10" style="line-height: 25px">
                    <option value="">请学选择-法律类型</option>
                    <c:forEach items="${columnInfoList }" var="c">
                        <option value="${c.id }"
                                <c:if test="${c.id == columnInfoQueryDTO.columnId }">selected</c:if>
                        >${c.name }</option>
                    </c:forEach>
                </select>
                <div class="t_button mgl30">
                    <a class="abtn red" href="javascript:myQuery();">
                        <i class="icon"></i>查询
                    </a>
                </div>
                <div class="t_button ml10">
                    <a class="abtn blue" href="javascript:myEdit();">
                        <i class="icon"></i>新增
                    </a>
                </div>
                <div class="t_label ml10">
                    记录数：<label style="color: red;" id="total">${page.totalCount }</label>
                </div>
            </div>

            <div class="J_table mt20">
                <div class="t_table">
                    <table>
                        <thead>
                        <tr>
                            <td>
                                <input type="checkbox" name="selectAll" id="selectAll" onclick="selectAllIds();" />
                            </td>
                            <td>
                                <span>标题</span>
                            </td>
                            <td>
                                <span>类别</span>
                            </td>
                            <td>
                                <span>发布者</span>
                            </td>
                            <td id="createDateTd"
                                    <c:choose>
                                        <c:when test = "${articleQueryDTO.createDateSortCss != null && articleQueryDTO.createDateSortCss != ''  }">
                                            class = "${articleQueryDTO.createDateSortCss}"
                                        </c:when>
                                        <c:otherwise>
                                            class="down"
                                        </c:otherwise>
                                    </c:choose>
                                data-type="sort">
                                <span>发布日期</span><i></i>
                            </td>
                            <td>
                                <span>操作</span>
                            </td>
                        </tr>
                        </thead>

                        <tbody>
                        <c:forEach items="${page.list }" var="p">
                            <tr >
                                <td>
                                    <div class="t_text tc">
                                        <input type="checkBox" name="selecteId" value="${p.id }" />
                                    </div>
                                </td>
                                <td>
                                    <div class="t_text tc">
                                            ${p.title }
                                    </div>
                                </td>
                                <td>
                                    <div class="t_text tc">
                                            ${p.columnInfo.name }
                                    </div>
                                </td>
                                <td>
                                    <div class="t_text tc">
                                            ${p.publisher }
                                    </div>
                                </td>
                                <td>
                                    <div class="t_text tc">
                                        <fmt:formatDate value="${p.createDate }" pattern="yyyy-MM-dd HH:mm:ss"/>
                                    </div>
                                </td>
                                <td>
                                    <div class="t_link">
                                        <a href="javascript:myEdit('${p.id }');"><i class="icon"></i>编辑</a>
                                       <a href="javascript:updDeleteFlag('${p.id }', '1');"><i class="icon"></i>删除</a>
                                    </div>
                                </td>
                            </tr>
                        </c:forEach>
                        </tbody>
                    </table>
                </div>
                <%@ include file="../../common/pager.jsp" %>
            </div>
        </form>
    </div>
</div>
<script src="${ctx }/static/plugins/chosen_v1.6.2/chosen.jquery.js"></script>
<script type="text/javascript">
    function myEdit(id) {
        window.location.href = '${ctx}/law/article/edit?id=' + id;
    }

    function mySubmit() {
        $('#editForm').submit();
    }

    function myQuery() {
        $('#queryForm').submit();
    }
    function updDeleteFlag(id, deleteFlag){
        var ids;
        if(id){
            ids = new Array();
            ids.push(id);
        }else{
            ids = getSelectIds();
        }

        var msg = deleteFlag == 1 ? '删除' : '恢复';

        if(!ids || ids.length == 0){
            layer.msg('请选择要'+msg+'记录');
            return;
        }

        layer.confirm('确定要' + msg + '记录吗？', function(index){
            layer.close(index);

            var loadIdx = layer.load();
            $.ajax({
                url : '${ctx}/law/article/ajax/delete',
                type : 'post',
                data : {
                    'ids' : ids,
                    'deleteFlag' : deleteFlag
                },
                traditional : true,
                success : function(result){
                    layer.close(loadIdx);
                    if(result.success){
                        layer.alert('操作成功', function(){
                            window.location.reload();
                        });
                    }else{
                        layer.alert('操作失败');
                    }
                }
            });
        });
    }
</script>
</body>
</html>